import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../views/Layout/index.vue'
import Login from '../views/Login/Login.vue'
import Home from '../views/Home/index.vue'
// import Goods from '../views/Goods/Goods'

//异步
const Goods = () => import('../views/Goods/Goods.vue')

const Params = () => import('../views/Params/Params.vue')

const Advert = () => import('../views/Advert/Advert.vue')

const Order = () => import('../views/Order/index.vue')

const OrderList = () => import('../views/Order/OrderList/index.vue')

const OrderBack = () => import('../views/Order/OrderBack/index.vue')

//子集路由
const AddGoods = () => import('../views/Goods/AddGoods.vue')

Vue.use(VueRouter)

const routes = [
    {
        path: "",
        component: Layout,   //主页
        //路由元信息
        meta: {
            isLogin: true
        },
        children: [
            {
                path: '/',
                name: 'Home',    //首页
                component: Home
            }, {
                path: '/goods',
                name: 'Goods',    //商品
                component: Goods
            }, {
                path:'/add-goods',
                name:'AddGoods',
                component:AddGoods
            },{
                path: '/params',
                name: 'Params',   //规格参数
                component: Params
            }, {
                path: '/advert',
                name: 'Advert',   //广告
                component: Advert
            }, {
                path: '/order',
                name: 'Order',   //
                component: Order,
                redirect: '/order/order-list',
                children: [
                    {
                        path: 'order-list',
                        component: OrderList
                    }, {
                        path: 'order-back',
                        component: OrderBack
                    }
                ]
            }
        ]
    },

    {
        path: "/login",
        name: 'Login',   //登录页
        component: Login,

    },

]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router;


